<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt" %>
<c:set var="ctx" value="${pageContext.request.contextPath}"/>

<!DOCTYPE HTML>
<html>
<head>
    <base href="${ctx }/">
    <meta http-equiv="Content-Type" content="text/html;charset=utf-8"/>
    <link rel="stylesheet" href="plugin/bootstrap-3.3.7-dist/css/bootstrap.min.css"/>
    <link rel="stylesheet" href="alert/alert.css">
    <style type="text/css">
        a{
        color: #73879C;
        }
    </style>
</head>
<body>
<div class="container-fluid">
<div class="container row" id="query">
        <div>
            <ul class="breadcrumb">
                <li>
                    <i class="icon-home home-icon"></i>
                    <a href="javascript:void(0)">Driver Management(司机管理)</a>
                </li>
                <li class="active">
                    <a href="view/driver/conf.jsp">Driver Cancellation Notice(取消订单设置)</a>
                </li>
            </ul>
        </div>
    <div class="container row">
        <div class="col-md-12">
            <h4>Driver Cancellation Notice(取消订单设置)</h4>
            <form class="form-inline" id="updateform">
                <input type="hidden" id="id" name="id">
                Daily Cancellation Number(司机每天取消订单)<input class="form-control" type="number" min="1" name="driverCancels" id="driverCancels"> Times (次),
                Suspend(禁止服务)<input class="form-control" type="number" min="0" id="bantime" name="bantime"> Minutes(分钟)
                <br><br>
                Driver Notification(编辑发送内容) ：<textarea class="form-control" name="driverCancelsSendContent"
                                 id="driverCancelsSendContent" cols="56" rows="5"></textarea>
                <br><br>
                <button class="btn btn-success" onclick="return update()">Save(更新)</button>
            </form>
        </div>
    </div>
</div>
</body>

<!-- 加载需要的js -->
<script src="js/jquery-3.2.1.min.js"></script>
<script src="plugin/bootstrap-3.3.7-dist/js/bootstrap.min.js"></script>
<script src='alert/alert.js'></script>
<script src="js/common.js"></script>
<script src="plugin/layer/layer.js"></script>
<script type="text/javascript" charset="utf-8">
    var M = {}

    $(function () {
        $.get(
            "user/driver/order/cancel/conf",
            {},
            function (json) {
                if (json.code == 200) {
                    $('#id').val(json.data.id);
                    $('#driverCancels').val(json.data.driverCancels);
                    $('#bantime').val(json.data.bantime);
                    $('#driverCancelsSendContent').val(json.data.driverCancelsSendContent);
                }else{
                    $("#id").val(1);
                }
            }
        )
    })

    function update() {
        var data = $('#updateform').serializeArray();
       /*  for(var i in data){
        	if(data[i].name=='driverCancelsSendContent'){//内容不能为空
        		
        	}
        } */
        var data =serialize('updateform');
        if(data.bantime==''){
        	alert("Time is not empty. ");
        	return;
        }
        if(data.driverCancels==''){
        	alert("Daily Cancellation Number is not empty.");
        	return;
        }
        if(data.driverCancelsSendContent==''){
        	alert("Suspension time is empty.");
        	return;
        }
        $.post(
            "user/driver/order/cancel/conf",
            data,
            function (json) {
                if (json.code == 200) {
                    M.dialog2 = jqueryAlert({
                        'title': 'Notification(提示)',
                        'content': '<p>Successful</p>',
                        'width': "320",
                        'modal': true,
                        'buttons': {
                            'OK': function () {
                                M.dialog2.close();
                            }
                        }
                    });
                } else {
                    M.dialog2 = jqueryAlert({
                        'title': 'Notification(提示)',
                        'content': '<p>Not Successful</p>',
                        'width': "320",
                        'modal': true,
                        'buttons': {
                            'ok': function () {
                                M.dialog2.close();
                            }
                        }
                    });
                }
                if (M.dialog2) {
                    return M.dialog2.show();
                }
            }
        )
        return false;
    }
</script>
</html>


